<template>
  <t-dialog
    :header="`${header}-经费回收`"
    :visible.sync="visible"
    :onClose="closeDialog"
    :closeOnOverlayClick="false"
    :confirmBtn="type === 'detail' ? null : '确定'"
    :cancelBtn="type === 'detail' ? '返回' : '取消'"
    @confirm="onSubmit"
    width="80%"
    top="5%"
  >
    <div style="height: 65vh">
      <add-edit-detail ref="addEditRef" @reload="reload" :type="type" :objId="objId"></add-edit-detail>
    </div>
  </t-dialog>
</template>
  
<script>
import AddEditDetail from './add-edit-detail.vue'

export default {
  name: 'add-edit-detail-dialog',
  components: {
    AddEditDetail,
  },
  props: {
    objId: [String, Number],
    header: String,
    type: {
      type: String,
      default: 'add'
    }
  },
  data() {
    return {
      visible: true,
    };
  },
  created() {},
  methods: {
    onSubmit() {
      this.$refs.addEditRef.submit()
    },
    closeDialog() {
      this.$emit('update:visible', false);
    },
    reload() {
      this.$emit('reload');
      this.$emit('update:visible', false);
    }
  },
};
</script>